package com.yundingai.domain.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.util.Date;
import java.util.List;

/**
 * 菜单表：用于动态查询生成后台菜单与动态路由实现
 * @TableName all_menu
 */
@TableName(value ="all_menu")
@Data
public class AllMenu {
    /**
     * 菜单id   
     */
    @TableId(type = IdType.AUTO)
    private Integer menuId;

    /**
     * 父菜单id
     */
    private Integer parentId;

    /**
     * 图标名称（element icon）
     */
    private String menuIcon;

    /**
     * 标题
     */
    private String menuTitle;

    /**
     * 路由地址
     */
    private String menuHref;

    /**
     * 组件名称
     */
    private String menuComp;

    /**
     * 启用状态：0关闭，1开启
     */
    private Integer isAvaliable;

    /**
     * 创建者
     */
    private String creator;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新人
     */
    private String updater;

    /**
     * 更新时间
     */
    private Date updateTime;

    //持有子菜单
//    private List<AllMenu> children;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        AllMenu other = (AllMenu) that;
        return (this.getMenuId() == null ? other.getMenuId() == null : this.getMenuId().equals(other.getMenuId()))
            && (this.getParentId() == null ? other.getParentId() == null : this.getParentId().equals(other.getParentId()))
            && (this.getMenuIcon() == null ? other.getMenuIcon() == null : this.getMenuIcon().equals(other.getMenuIcon()))
            && (this.getMenuTitle() == null ? other.getMenuTitle() == null : this.getMenuTitle().equals(other.getMenuTitle()))
            && (this.getMenuHref() == null ? other.getMenuHref() == null : this.getMenuHref().equals(other.getMenuHref()))
            && (this.getMenuComp() == null ? other.getMenuComp() == null : this.getMenuComp().equals(other.getMenuComp()))
            && (this.getIsAvaliable() == null ? other.getIsAvaliable() == null : this.getIsAvaliable().equals(other.getIsAvaliable()))
            && (this.getCreator() == null ? other.getCreator() == null : this.getCreator().equals(other.getCreator()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getUpdater() == null ? other.getUpdater() == null : this.getUpdater().equals(other.getUpdater()))
            && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getMenuId() == null) ? 0 : getMenuId().hashCode());
        result = prime * result + ((getParentId() == null) ? 0 : getParentId().hashCode());
        result = prime * result + ((getMenuIcon() == null) ? 0 : getMenuIcon().hashCode());
        result = prime * result + ((getMenuTitle() == null) ? 0 : getMenuTitle().hashCode());
        result = prime * result + ((getMenuHref() == null) ? 0 : getMenuHref().hashCode());
        result = prime * result + ((getMenuComp() == null) ? 0 : getMenuComp().hashCode());
        result = prime * result + ((getIsAvaliable() == null) ? 0 : getIsAvaliable().hashCode());
        result = prime * result + ((getCreator() == null) ? 0 : getCreator().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getUpdater() == null) ? 0 : getUpdater().hashCode());
        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", menuId=").append(menuId);
        sb.append(", parentId=").append(parentId);
        sb.append(", menuIcon=").append(menuIcon);
        sb.append(", menuTitle=").append(menuTitle);
        sb.append(", menuHref=").append(menuHref);
        sb.append(", menuComp=").append(menuComp);
        sb.append(", isAvaliable=").append(isAvaliable);
        sb.append(", creator=").append(creator);
        sb.append(", createTime=").append(createTime);
        sb.append(", updater=").append(updater);
        sb.append(", updateTime=").append(updateTime);
        sb.append("]");
        return sb.toString();
    }
}